<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>命令模式</title>
</head>
<body>
<script type="text/javascript">
    var lian={};
    lian.paobing=function(pao_num){
        alert(pao_num + '炮'+'开始战斗');
    };
    lian.buping=function(buping_num){
        alert(buping_num +'人'+'开始战斗');
    };
    lian.lianzhang=function(mingling){
        lian[mingling.type](mingling.num);
    };
    //总司令开始发令
    lian.lianzhang({
        type:'paobing',
        num:100
    });
    lian.lianzhang({
        type:'buping',
        num:500
    })
</script>
</body>
</html>